package com.ruoyi.provider;

import com.ruoyi.auth.AuthenticationConfigurationProvider;
import com.ruoyi.auth.UnifiedAuthenticationSettings;
import com.ruoyi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
//import org.springframework.stereotype.Service;

@Component
public class DbAuthenticationConfigurationProvider implements AuthenticationConfigurationProvider {

    @Autowired
    private ISysConfigService configService;

    @Override
    public UnifiedAuthenticationSettings getUnifiedAuthenticationSettings() {

        UnifiedAuthenticationSettings settings = new UnifiedAuthenticationSettings();
        // TODO 这里要批量从数据库中读取数据， 获取 sso-  开头的数据
        settings.setApplicationId(configService.selectConfigByKey("sso-application-id"));
        settings.setPrivateKey(configService.selectConfigByKey("sso-private-key"));
        settings.setApplicationWord(configService.selectConfigByKey("sso-application-word"));

        return settings;
    }
}
